<?php
include("../controllers/read.php");
$db = openDB("../database.sqlite");
$config = getConfig($db);
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<wiki name="<?php echo $config['name'] ?>" tagline="<?php echo $config['tagline'] ?>" url="<?php echo $config['url'] ?>">
<?php
$pages = sqlite_fetch_all(sqlite_query($db,"SELECT * FROM pages"));
foreach($pages as $page) {
  echo "  <page title='".$page['title']."' tags='".$page['tags']."'>\n";
  $pageid = $page['id'];
  $revisions = sqlite_fetch_all(sqlite_query($db,"SELECT * FROM revisions WHERE pageid = $pageid"));
  foreach($revisions as $revision) {
  	echo "    <revision time='".$revision['time']."' author='".$revision['author']."' ip='".$revision['ip']."'>";
  	echo $revision['body'];
  	echo "</revision>\n";
  }
  echo "  </page>\n";
}
?>
</wiki>